﻿@using DNA.Mvc.Text;
@using DNA.Mvc.Security;
@model Article
@{
    Layout = "~/Areas/Publishing/Views/Shared/_ContentLayout.cshtml";
    var context = WebSiteContext.Current;
    var _article = new ArticleWrapper(Model);
    var _content = _article.GetGlobalizationContent(); 
}

<h1 class="dna-post-title">
    @_content.Title
</h1>
<hr />
<div style="overflow: hidden; display: block; margin: 5px 0px 5px 0px; padding-top: 5px;">
    @Html.ImageLinkList().Options(opts =>
   {
       opts.CssClass = "ui-helper-reset";
       opts.ItemCssStyleText = "float:left;margin-right:5px;";
       opts.ImageCssStyleText = "float:left;margin-right:2px;";
       opts.TitleCssStyleText = "float:left;padding-top:2px;";
   }).Items(items =>
   {
       items.Add(Html.Global(Model.Posted), Url.Content("~/Content/Images/calender.gif"));
       items.Add(new SelectableNode()
       {
           Title = Html.Global("publishing", "PermalinkUrl"),
           ToolTip = "Open in new window.",
           Target = "_blank",
           ImageUrl = Url.Content("~/Content/Images/icon_content_link.gif"),
           NavigateUrl = _article.PermaLink
       });

       if (((context.Web.IsRoot) && (context.IsAuthorized<DNA.Mvc.Publishing.Controllers.ArticleController>("Edit"))) ||
        (context.User.IsWebOwner()))
           items.Add(new SelectableNode()
           {
               Title = Html.Global("RES_EDIT"),
               ImageUrl = Url.Content("~/Content/Images/edit_page.png"),
               NavigateUrl = Url.Action("Edit", "Article", new { website = context.Web.Name, id = Model.ID, Area = "Publishing" }),
               Target = "_top"
           });
   }).Render()
</div>
<div style="padding: 10px; margin: 5px; clear: both;" id="viewContent_bodyArea">
    @if (Model.ContentFormat == 2)
    {
        @TextEngine.Wiki(_content.Body, topicCssClass: "d-topic")
        Html.RegisterStartupScript("var _topic=$('.d-topic'); if (_topic.length) { _topic.dtree(); _topic.before(\"<b>Content table</b>\");}");
    }
    else
    { 
        @MvcHtmlString.Create(_content.Body)
    }
    @{ Html.ForceImageAutoSize("viewContent_bodyArea", -1, 600); }
</div>
@Publishing.ShareTo(_article)
<div style="margin: 20px 0px 10px 0px; border-top: 1px solid #cccccc; padding-top: 10px;
    color: Gray;">
    @context.Web.Copyright
</div>
@Html.StartupScripts()